/** @jsxImportSource @emotion/react */
import * as React from "react";
import {
    Text,
    LineColumn,
    InputLine,
    TextArea,
    Input,
    Select,
    Button,
    useTheme,
    Table,
    TableBody,
    TableRow,
    CCell,
    Layer, TableHead, Cell, SuffixInput, BlobInputList, InputDatalist, CheckSwitch,
} from "customize-easy-ui-component";
import {
    InspectRecordLayout, InternalItemProps, SelectHookfork, useItemInputControl,
} from "../common/base";
import {useMeasureInpFilter} from "../common/hooks";
import {arraySetInp, calcAverageArrObj, objNestSet} from "../../common/tool";
import {items漏磁检} from "../park/editor";
import { JSX } from "@emotion/react/jsx-runtime";

interface Props extends InternalItemProps {
    label?: string;
    titles?: any[];
}

//常见模型：{特别的配置 } 第三个字段标识：是否标题也是手工录入的？
export const item宏观检验o = [['道布置', {t: '管道布置', pr: '结构检验', span: 5},],
    ['支吊架', {t: '支吊架',},],
    ['膨胀节', {t: '膨胀节',},],
    ['开孔补', {t: '开孔补强',},],
    ['排放装', {t: '排放装置设置',},],
    ['焊口错', {t: '焊缝对口错边量', pr: '几何尺寸检验', span: 3}],
    ['咬边', {t: '咬边',}],
    ['焊余高', {t: '焊缝余高'}],
    ['道标志', {t: '管道标志', pr: '外观检验', span: 6}],
    ['电弧灼', {t: '管道组成件及其焊缝的腐蚀、裂纹、泄漏、鼓包、变形、机械接触损伤、过热、电弧灼伤'}],
    ['承件变', {t: '管道支承件变形、开裂'}],
    ['排堵塞', {t: '排放（疏水、排污）装置的堵塞、腐蚀、沉积物'}],
    ['腐层破', {t: '防腐层的破损、剥落'}],
    ['热层腐', {t: '隔热层破损、脱落、潮湿以及隔热层下的腐蚀和裂纹等'}],
    ['宏其他', {pr: '其他', span: 1}, true]];
export const itemA宏观检验: string[] = ['宏观结果'];
item宏观检验o.forEach(([name, title, initIsp], i: number) => {
    itemA宏观检验.push(name as string);
});
const 检验结果选=['符合要求','基本符合要求','不符合要求'];
export const 等级评定选=['1级','2级','3级','4级'];
/**宏观检验报告-结构几何尺寸
 * */
export const Structural =
React.forwardRef((
    {children, show, alone = true, redId, nestMd, label, titles}: Props, ref
) => {
    const [getInpFilter] = useMeasureInpFilter(null, itemA宏观检验,);
    const {inp, setInp} = useItemInputControl({ref});
    let oldPrefic='';
    return <InspectRecordLayout inp={inp} setInp={setInp} getInpFilter={getInpFilter} show={show} redId={redId}
                            nestMd={nestMd} alone={alone} label={label!}>
             <Text variant="h5">{label}：</Text>
                { item宏观检验o.map(([name,conf,adddesc]: any, i:number) => {
                    const {t: title, pr: prefix, span}=conf;
                    oldPrefic=prefix? prefix:oldPrefic;             //配置可继承性
                    return (<React.Fragment key={i}>
                        项目{i+1} {oldPrefic} {'>'} {title}：
                        <LineColumn key={i}>
                            {adddesc && <InputLine  label={'检验项目的附加叙述标题'}>
                                   <BlobInputList  value={inp?.[name]?.a ||''}
                                                onListChange={v => objNestSet(name,'a', v||undefined,inp,setInp) } />
                                </InputLine>
                            }
                            <InputLine label={'检验结果'}>
                                <InputDatalist value={(inp?.[name]?.r) || ''} datalist={检验结果选}
                                               onListChange={v => objNestSet(name,'r', v||undefined,inp,setInp) } />
                            </InputLine>
                            <InputLine  label={'备注'}>
                                <BlobInputList  value={inp?.[name]?.m ||''} datalist={['见结果栏']}
                                                onListChange={v => objNestSet(name,'m', v||undefined,inp,setInp) } />
                            </InputLine>
                            <InputLine label={'等级评定'}>
                                <InputDatalist value={(inp?.[name]?.c) || ''} datalist={等级评定选}
                                               onListChange={v => objNestSet(name,'c', v||undefined,inp,setInp) } />
                            </InputLine>
                        </LineColumn>
                    </React.Fragment>);
                })
                }
            <Text variant="h5">结果：</Text>表中检验项目备注无法说明清楚的，可在本栏中进一步将缺陷（问题）情况描述清楚：
            <TextArea  value={inp?.宏观结果 ||''} rows={13}
                       onChange={e => setInp({ ...inp, 宏观结果: e.currentTarget.value||undefined}) } />
    </InspectRecordLayout>;
});

